package com.team.bus.module.role.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.team.bus.module.menu.model.Menu;
import com.team.bus.module.user.model.User;

@Entity
@Table(name = "trole",schema = "miaoxu")
public class Role implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private String id;
	private Date createdatetime;
	private String description;
	private String text;
	private Integer orderno;
	private Date updatedatetime;
	private Set<User> users = new HashSet<User>(0);
	private Set<Menu> menus = new HashSet<Menu>(0);
	private String resourceIds;
	private String remark;
	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(name = "id", unique = true, nullable = false, length = 50)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "createdatetime", length = 50)
	public Date getCreatedatetime() {
		return this.createdatetime;
	}

	public void setCreatedatetime(Date createdatetime) {
		this.createdatetime = createdatetime;
	}

	@Column(name = "description", length = 200)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "text", length = 50)
	public String getText() {
		return this.text;
	}

	public void setText(String text) {
		this.text = text;
	}

	@Column(name = "orderno")
	public Integer getOrderno() {
		return this.orderno;
	}

	public void setOrderno(Integer orderno) {
		this.orderno = orderno;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "updatedatetime", length = 50)
	public Date getUpdatedatetime() {
		return this.updatedatetime;
	}

	public void setUpdatedatetime(Date updatedatetime) {
		this.updatedatetime = updatedatetime;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "tuser_role", schema = "", 
	joinColumns = { @JoinColumn(name = "roleid", nullable = false, updatable = false) }, 
	inverseJoinColumns = { @JoinColumn(name = "userid", nullable = false, updatable = false) })
	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "trole_menu", schema = "", 
	joinColumns = { @JoinColumn(name = "roleid", nullable = false, updatable = false) }, 
	inverseJoinColumns = { @JoinColumn(name = "menuid", nullable = false, updatable = false) })
	public Set<Menu> getMenus() {
		return menus;
	}

	public void setMenus(Set<Menu> menus) {
		this.menus = menus;
	}

	public String getResourceIds() {
		return resourceIds;
	}

	public void setResourceIds(String resourceIds) {
		this.resourceIds = resourceIds;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	
	

}